/**
 * 
 */
package com.tidux.app.tiduxbooker.activity;

import android.content.ContentValues;
import android.content.Intent;
import android.hardware.Camera;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import com.tidux.app.tiduxbooker.common.CameraPreview;
import com.tidux.app.tiduxbooker.provider.Summary;

/**
 * @author ren.tangr
 * 
 */
public class SummaryEditor extends TiduxActivity {

	private EditText edtSummaryContent;
	private Button btnCancelSummary;
	private Button btnSaveSummary;
	private Button btnCamera;
	private SurfaceView cameraPreviewSV;
	private ImageView imageView;
	
	private final static int CAMERA_SUMMARY_PIC_REQUEST = 0;
	
	SurfaceHolder mHolder;
	Camera mCamera;

	private CameraPreview cameraPreview;
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.summary_editor);

		Intent originIntent = getIntent();

		edtSummaryContent = findViewByViewID(R.id.edtSummaryContent);
		btnCancelSummary = findViewByViewID(R.id.btnCancelSummary);
		btnSaveSummary = findViewByViewID(R.id.btnSaveSummary);
		btnCamera = findViewByViewID(R.id.btnCamera);

		final String bookId = originIntent.getExtras().getString(
				Summary.BOOK_ID);

		btnSaveSummary.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				ContentValues values = new ContentValues();
				values.put(Summary.CONTENT, edtSummaryContent.getText()
						.toString());
				values.put(Summary.BOOK_ID, bookId);
				getContentResolver().insert(Summary.CONTENT_URI, values);
				finish();
			}
		});
		
		btnCamera.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
			    Intent cameraIntent = new Intent();
                cameraIntent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(cameraIntent, CAMERA_SUMMARY_PIC_REQUEST);
			}
		});

		btnCancelSummary.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				finish();
			}
		});

	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	    if(CAMERA_SUMMARY_PIC_REQUEST == requestCode && resultCode == RESULT_OK){
	        
	    }
	}

}
